{extend name="base" /}
{block name="css"}
{css href="__CSS__/login.css" /}
{/block}
{block name="body"}
<!-- 主要内容 开始 -->
<div class="weui-tab__panel">
  <div class="weui-ad">
    <img src="/static/images/logo-white.png">
    <p class="demos-sub-title f-white">{$config.sitename|default=$Think.lang.title}</p>
  </div>
  <div class="weui-cells weui-cells_form">
    <div class="weui-cell">
      <div class="weui-cell__hd">
        <label class="weui-label">用户名</label>
      </div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="tel" pattern="[0-9]*" maxlength="11" id="name" placeholder="请输入手机号">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd">
        <label class="weui-label">密码</label>
      </div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="password" id="pwd" placeholder="请输入密码">
      </div>
    </div>
    {notempty name="$config.vercode"}
    <div class="weui-cell weui-cell_vcode">
      <div class="weui-cell__hd">
        <label class="weui-label">验证码</label>
      </div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" id="captcha" placeholder="请输入验证码">
      </div>
      <div class="weui-cell__ft">
        <img class="weui-vcode-img">
      </div>
    </div>
    {/notempty}
    <div class="weui-btn-area">
      <button class="weui-btn weui-btn_primary">确定</button>
    </div>
  </div>
</div>

<div class="forgets">
	<a href="forget.html">忘记密码？</a>
	<a href="register.html">免费注册</a>
</div>
<div class="weui-btn-area wechat" style="display: none;">
    <div class="login-icon">
        <img src="__IMG__/wechat/wechat.png" alt="">
    </div>
</div>
<!-- 主要内容 结束 -->
{/block}
{block name="js"}
<script type="text/javascript">
  $(function () {
    $('.weui-btn').click(function () {
      var user_name = $.trim($('#name').val());
      var user_pwd = $.trim($('#pwd').val());
      var captcha = $.trim($('#captcha').val());
      if (!user_name) return $.toptip('用户名不能为空!');
      else if (!user_pwd) return $.toptip('密码不能为空!');
      else $.post('login.html',{user_name:user_name,user_pwd:user_pwd,captcha:captcha},function(result) {
        if (result.code === 1) {
          $.toast(result.msg,'text');
          setTimeout(function(){
            location.href = result.url;
          },1000);
        } else {
          $.toptip(result.msg);
        }
      });
    });
    /* 图形验证码 */
    var captchaUrl = '/captcha.html';
    $('img.weui-vcode-img').click(function () {
      this.src = captchaUrl + '?t=' + (new Date).getTime();
    }).trigger('click');
    //微信、小程序内显示微信登陆
    /*
    is_weixin() && $(".wechat").show();
    $('.login-icon').click(function() {
      if(is_weixin()){
        wx.miniProgram.getEnv(function(res) {
          if (res.miniprogram) {
            $.alert('小程序');
          }else {
            $.alert('公众号');
          }
        });
      }
    });
    */
  });
</script>
{/block}